package com.example.project.controller;

import com.example.project.pojo.Result;
import com.example.project.pojo.Article;
import com.example.project.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/article")
public class ArticleController {
     @Autowired
     private ArticleService articleService;
     //获取所有文章信息
     @GetMapping("/list")
    public Result<List<Article>> list(){
        List<Article> list=articleService.getlist();


        return  Result.success(list);
    }
   @PostMapping
    public  Result add(@RequestBody Article article){
         articleService.add(article);

         return Result.success();
    }

    @GetMapping("/article/Mylist")
    public Result mylist(@RequestBody int id){
      List list =  articleService.mylist(id);
         return Result.success(list);
    }


}
